<?php


require "database.php";

$__user___=file_get_contents("user.json");
$__user___=json_decode($__user___,1);
$username=$_POST["username"];
$password=$_POST["password"];
for ($i = 0; $i < count($__user___); $i++) {
    if($__user___[$i]["username"]==$username){
        return json([
            "code"=>404,
            "msg"=>"账号已注册"    
        ]);
    }
}
$__d__=[
    "id"        =>count($__user___)+1,
    "username"  =>$username,
    "password"  =>$password
];
$__user___[count($__user___)]=$__d__;
$__user___=json_encode($__user___,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
file_put_contents("user.json",$__user___);
return json([
    "code"=>200,
    "msg"=>"success"    
]);






